// Use IPUMS dataset 2011

// outcomes
gen inactive=(empstatd==390)
replace inactive=. if empstatd==0|empstatd==999

gen lfp=(inactive==0)
replace lfp=. if inactive==.

gen employed=.
replace employed=1 if empstat==1
replace employed=0 if empstat==2|empstat==3

gen married=(marst==2)
replace married=. if marst==0|marst==9

gen secondary=(edattain>=3)
replace secondary=. if edattain==0|edattain==9

gen university=(educfr==51|educfr==52)
replace university=. if educfr==0|educfr==99

gen endogamous=(bplcountry_sp==bplcountry_pop)
replace endogamous=. if bplcountry_sp==.|bplcountry_sp==0

gen children=(nchild>0)
replace children=. if nchild==. 

// muslim countries/regions
drop if bplcountry_pop==.
gen muslim=(bplcountry_pop==13010|bplcountry_pop==13040|bplcountry_pop==13060|bplcountry_pop==34160)
gen algeria=(bplcountry_pop==13010)
gen morocco=(bplcountry_pop==13040)
gen tunisia=(bplcountry_pop==13060)
gen turkey=(bplcountry_pop==34160) 

// nativity
gen native=(nativity==1)
replace native=. if nativity==0|nativity==9

// female
gen female=(sex==2)

// treated cohort-interaction
gen treatedcoh=(birthyr>=1986)
gen inter=muslim*treatedcoh

// restrict dataset			
drop if (bplcountry_pop==19990|bplcountry_pop==69900|bplcountry_pop==49999) 
keep if native
keep if birthyr>=1980
drop if age<20

save ipums, replace
